package com.yidu.hbatsft.action;

import com.yidu.hbatsft.domain.AtsSchemeAthlete;
import com.yidu.hbatsft.domain.AtsSchemeAudit;
import com.yidu.hbatsft.service.MentalityAtsSchemeAthleteService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
  *@ClassName MentalityAtsSchemeAthleteController
  *@Description 方案对应的运动员控制类
  *@Author 肖瑜
  *@Date 2020/1/9 9:51
  *@Version 1.0
**/
@Controller
@RequestMapping("/mentalityAthlete")
public class MentalityAtsSchemeAthleteController {

    //方案对应的运动员service
    @Resource
    MentalityAtsSchemeAthleteService masAthlete;


    /**
     * 根据方案ID查询
     * @param id 方案ID
     * @return list 集合
     */
    @RequestMapping("findBySchemeId")
    @ResponseBody
    public List<AtsSchemeAthlete> findBySchemeId(Integer id){
        //调用根据方案ID查询方法
        return masAthlete.selectbyschemeidKF(id);
    }


    /**
     * 查询所有案对应的运动员
     * @param pageNum 页数
     * @param pageSize 条数
     * @param athlete 方案对应的运动员对象
     * @return map 集合
     */
    @RequestMapping("selectAllAthlete")
    @ResponseBody
    public Map<String, Object> selectAllAthlete(@RequestParam("page") Integer pageNum, @RequestParam("limit") Integer pageSize,AtsSchemeAthlete athlete){
        //创建map集合
        Map<String, Object> map = new HashMap<String, Object>();
        //调用查询所有案对应的运动员
        List<AtsSchemeAthlete> athletes = masAthlete.selectAllAthlete(pageNum, pageSize,athlete);
        //将code设置为0
        map.put("code", 0);
        //将msg设置为空
        map.put("msg", "");
        //统计条数放入map
        map.put("count", masAthlete.count(athlete));
        //将集合放入map
        map.put("data", athletes);
        //返回集合
        return map;
    }
}
